using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Silvery;

namespace Sample01_Base
{
    //GameRoot的使用，该例子展示了热键操作
    public class Sample_3 : GameRoot
    {
        public Sample_3()
            :base(App.Current.RootVisual as FrameworkElement)
        {
            //声明一个热键
            var hotkey = new Silvery.GameControls.HotKey(Key.A);
            //为热键加事件
            hotkey.HotKeyActivated += new Silvery.GameControls.KeyHotEventHandler(hotkey_HotKeyActivated);
            //添加热键到一个组里面,HotKeys是IGameRoot接口
            HotKeys.Add("测试", hotkey);
            //声明一个组合热键，当前只支持两键的组合
            hotkey = new Silvery.GameControls.HotKey(Key.G, ModifierKeys.Control);
            hotkey.HotKeyActivated+=new Silvery.GameControls.KeyHotEventHandler(hotkey_HotKeyActivated);
            HotKeys.Add("测试2", hotkey);
            //这是一个显示而已
            this.Children.Add(new TextBlock() { Text = "快捷键测试：A ,Ctrl+G", FontSize = 32 });
        }

        void hotkey_HotKeyActivated(Silvery.GameControls.HotKey hotkey)
        {
            var s = "快捷键：" + hotkey.RegistKey.ToString() + "按下";
            if (hotkey.RegistModifierKeys != ModifierKeys.None)
            {
                s += "\n组合键：" + hotkey.RegistModifierKeys.ToString();
            }
            MessageBox.Show(s);
        }
    }
}
